import React from 'react';
import { Radio } from 'antd';
import { useDispatch, useSelector } from 'react-redux';
import { replaceMenus } from '@/store/counterSlice';

const Test = () => {
  const dispatch = useDispatch();
  const role = useSelector(((state: any) => state.counter.role));

  function onChange(e: any) {
    dispatch(replaceMenus({ role: e.target.value }));
  }

  return (
    <div>
      <div style={{ marginBottom: 40 }}>你的权限：{role}</div>
      <Radio.Group onChange={onChange} value={role}>
        <Radio.Button value="editor">editor</Radio.Button>
        <Radio.Button value="admin">admin</Radio.Button>
      </Radio.Group>
    </div>
  );
};

export default Test;
